package com.magic.gre.mvp.presenter;

import com.google.gson.reflect.TypeToken;
import com.magic.gre.entity.base.BaseObjectModel;
import com.magic.gre.mvp.contract.GuideContract;
import com.magic.gre.mvp.model.GuideModelImpl;
import com.noname.lib_base_java.mvp.BasePresenterImpl;

import java.util.Map;

/**
 * Author: Lmoumou
 * Date: 2019-01-11 16:26
 * 文件名: GuidePresenterImpl
 * 描述:
 */
public class GuidePresenterImpl extends BasePresenterImpl<GuideContract.View, GuideContract.Model>
        implements GuideContract.Presenter {
    public GuidePresenterImpl(GuideContract.View view) {
        super(view);
    }

    @Override
    protected GuideContract.Model creatModel() {
        return new GuideModelImpl();
    }

    @Override
    public void pSaveGuide(Map<String, Object> parmsMap) {
        mModel.mSaveGuide(new CommonObserver<BaseObjectModel>(new TypeToken<BaseObjectModel>(){}.getType()) {
            @Override
            protected void onSuccess(BaseObjectModel baseObjectModel) {
                mView.vSaveGuide();
            }

            @Override
            public void onError(int status, String msg) {
                mView.doPrompt(msg);
            }
        }, parmsMap);
    }
}
